#include "index/attribute_index/attribute_mem_indexer/attribute_mem_indexer.h"

namespace hawking {
namespace indexlib {

Status AttributeMemIndexer::BatchRead(SegmentContext* segment_ctx) {
    std::vector<DocContext>& doc_ctxs = *(segment_ctx->MutableDocContext());
    for (size_t idx = 0; idx < segment_ctx->DocIds().size(); ++idx) {
        if (doc_ctxs[idx].filtered) {
            continue;
        }

        util::FieldValue* field_value =
            segment_ctx->ArenaCtx().CreateOnArena<util::FieldValue>();
        doc_ctxs[idx].field2attr.emplace(field_id_, field_value);

        Status ret = ReadOneDoc_(segment_ctx->DocIds()[idx], field_value);
        if (ret != Status::OK) {
            return ret;
        }
    }

    return Status::OK;
}

}
}